package com.anlogic.sdk.utils.options;

import java.util.LinkedHashMap;
import java.util.Map;

public enum CpuType {
	RPU("rpu", "rpu"), A35_0("a35-0", "apu-0"), A35_1("a35-1", "apu-1"), A53_0("a53-0", "apu-0"), A53_1("a53-1", "apu-1"), A53_2("a53-2", "apu-2"), A53_3("a53-3", "apu-3");

	private String id;

	private String name;

	private static Map<String, CpuType> idMap = new LinkedHashMap<>();

	static {
		for (CpuType value : CpuType.values()) {
			idMap.put(value.getId(), value);
		}
	}

	CpuType(String id, String name) {
		this.id = id;
		this.name = name;
	}

	public String getName() {
		return this.name;
	}

	public String getId() {
		return this.id;
	}

	public static String[] getIds() {
		return idMap.keySet().toArray(new String[0]);
	}

	public static CpuType getTypeById(String id) {
		return idMap.get(id);
	}

	public static CpuType getTypeByName(ChipType chip, String name) {
		for (CpuType cpu : ChipType.getCpuList(chip.getName())) {
			if (cpu.getName().equals(name)) {
				return cpu;
			}
		}
		return null;
	}
}
